# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/11 22:10
# @Author   : Robot-Zsj
"""
description:

input
10 8 36 15 7
output
44
"""
wa, wb, wt, pa, pb = map(int, input().split())

minX = 1
maxX = (wt - wb) // wa
ans = 0

for x in range(minX, maxX + 1):
    remain = wt - wa * x

    if remain % wb == 0:
        y = remain // wb
        ans = max(ans, pa * x + pb * y)

print(ans)
